package com.acme;

import com.acme.bankapp.domain.bank.Client;
import com.acme.bankapp.service.bank.BankService;
import com.acme.exceptions.ClientExistException;
import com.acme.exceptions.NotEnoughFundsException;
import com.acme.exceptions.OverDraftLimitExceededException;

public class BankApplication {
	private final static String clientName0 = "Jack Will";
	private final static String clientName1 = "Sue Cherton";
	private final static String clientName2 = "Mi Lee";
	private final static String clientName3 = "Carl Black";
	private final static String clientName4 = "Sharon Adel";
	private final static String s0 = "The requested amount is: ";
	private final static String s1 = ", the max sum for amount is: ";
	private final static String s2 = "Not enough funds, need to use overdraft";
	private final static String s3 = "There is a client with such name in bank";

	public static void main(String[] args) {
		BankService bankService = new BankService();

		try {
			bankService.addClient(new Client(1000, 1000, 2000, clientName0,
					true));
			bankService.addClient(new Client(2000, 2000, 2000, clientName1,
					false));
			bankService.addClient(new Client(3000, 3000, 2000, clientName2,
					true));
			bankService.addClient(new Client(4000, 4000, 2000, clientName3,
					true));
			bankService.addClient(new Client(5000, 5000, 2000, clientName4,
					false));
		} catch (ClientExistException e) {
			System.out.println(s3);
		}
		try {
			bankService.addClient(new Client(8000, 2000, 12000, clientName4,
					false));
		} catch (ClientExistException e) {
			System.out.println(s3);
		}

		System.out.println();
		bankService.printBalance();
		System.out.println();

		try {
			bankService.modifyBank(bankService.bank.clients.get(0), 300, false);
		} catch (OverDraftLimitExceededException e) {
			System.out.println(s0 + e.getAmount() + s1 + e.getMaxSum());
		} catch (NotEnoughFundsException e) {
			System.out.println(s2);
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println();

		try {
			bankService
					.modifyBank(bankService.bank.clients.get(1), 2100, false);

		} catch (OverDraftLimitExceededException e) {
			System.out.println(s0 + e.getAmount() + s1 + e.getMaxSum());
		} catch (NotEnoughFundsException e) {
			System.out.println(s2);
		} catch (Exception e) {
			e.printStackTrace();
		}
		System.out.println();

		try {
			bankService.modifyBank(bankService.bank.clients.get(3), 10000,
					false);

		} catch (OverDraftLimitExceededException e) {
			System.out.println(s0 + e.getAmount() + s1 + e.getMaxSum());
		} catch (NotEnoughFundsException e) {
			System.out.println(s2);
		} catch (Exception e) {
			e.printStackTrace();
		}

		System.out.println();
		bankService.printBalance();
		System.out.println();

		System.out.println(bankService.bank.clients.get(2).accountC
				.equals(bankService.bank.clients.get(2).accountS));
		System.out.println(bankService.bank.clients.get(3).accountC
				.equals(bankService.bank.clients.get(2).accountC));
		System.out.println(bankService.bank.clients.get(2).accountC
				.equals(bankService.bank.clients.get(2).accountC));

		bankService.bank.clients.get(4).accountC.decimalValue();
		bankService.bank.clients.get(4).accountS.decimalValue();

	}

}
